package io.gitee.zhangbinhub.acp.cloud

import io.gitee.zhangbinhub.acp.boot.constant.AcpCoreConstant
import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.acp.cloud.component.CloudLogAdapter
import io.gitee.zhangbinhub.acp.cloud.conf.AcpCloudLogServerClientConfiguration
import io.gitee.zhangbinhub.acp.cloud.constant.AcpCloudConstant
import io.gitee.zhangbinhub.acp.cloud.tools.CloudTools
import org.noear.solon.annotation.Bean
import org.noear.solon.annotation.Condition
import org.noear.solon.annotation.Configuration
import org.noear.solon.annotation.Inject

@Configuration
@Condition(onProperty = "\${${AcpCloudConstant.LOG_SERVER_CLIENT_PROPERTIES_PREFIX}.enabled}=true")
class AcpCloudLogConfiguration {
    @Bean(priority = AcpCoreConstant.LOG_COMPONENT_PRIORITY + 1)
    @Condition(onMissingBean = LogAdapter::class)
    fun logAdapter(
        @Inject cloudTools: CloudTools,
        @Inject acpCloudLogServerClientConfiguration: AcpCloudLogServerClientConfiguration
    ): LogAdapter = CloudLogAdapter(cloudTools, acpCloudLogServerClientConfiguration)
}